package service

import (
	"context"
	"course-hub/user-srv/basic/handler/model"
	__ "course-hub/user-srv/basic/proto"
)

type Serve struct {
	__.UserClient
}

func (s *Serve) Register(_ context.Context, in *__.RegisterReq) (*__.RegisterResp, error) {

	var user model.User
	user = model.User{
		Username: user.Username,
		Password: user.Password,
		Tel:      user.Tel,
		Status:   user.Status,
		Qx:       user.Qx,
		Js:       user.Js,
	}
	err := model.Register(&user)
	if err != nil {
		return &__.RegisterResp{
			Code: 0,
			Msg:  "添加失败",
		}, nil
	}
	return &__.RegisterResp{
		Code: 200,
		Msg:  "添加成功",
	}, nil
}

func (s *Serve) Create(ctx context.Context, in *__.CreateReq) (*__.CreateResp, error) {
	var school model.School

	school = model.School{
		Name:  school.Name,
		Phone: school.Phone,
		Email: school.Email,
		Logo:  school.Logo,
	}
	err := model.Create(&school)
	if err != nil {
		return &__.CreateResp{
			Code: 0,
			Msg:  "添加失败",
		}, nil
	}
	return &__.CreateResp{
		Code: 200,
		Msg:  "添加成功",
	}, nil
}
